package com.shx.bill.mapper;

import com.shx.bill.entities.Provider;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ProviderMapper {

    @Select("select * from provider where " +
            "providerName is not null " +
            "and providerName != '' " +
            "and providerName like '%${providerName}%' ")
    List<Provider> getProviderList(Provider provider);

    @Select("select * from provider where pid=#{pid}")
    Provider getProviderByPid(Integer pid);

    // 指定自增属性
    @Options(useGeneratedKeys = true, keyProperty = "pid")
    @Insert("insert into provider(provider_code, providerName, people, phone, address, fax, description) " +
            "values(#{providerCode}, #{providerName}, #{people}, #{phone}, #{address}, #{fax}, #{description})")
    int addProvider(Provider provider);

    @Delete("delete from provider where pid=#{pid}")
    int deleteProvider(Integer pid);

    @Update("update provider set " +
            "providerName=#{providerName}, " +
            "people=#{people}, phone=#{phone}, address=#{address}, fax=#{fax}, description=#{description} " +
            "where pid=#{pid} ")
    int updateProvider(Provider provider);

}
